#!/bin/bash

# Docker状态检查脚本
# 用于检查EasyStorage模拟数据服务状态

echo "=== EasyStorage Docker 状态检查 ==="

# 检查docker-compose是否安装
if ! command -v docker-compose &> /dev/null; then
    echo "错误: docker-compose未安装"
    exit 1
fi

# 显示容器状态
echo "容器状态:"
docker-compose ps

echo ""
echo "容器详细信息:"
docker-compose ps --services | while read service; do
    echo "服务: $service"
    docker-compose logs --tail=10 $service
    echo "---"
done

# 检查端口占用
echo "端口占用情况:"
netstat -tlnp | grep :18091 || echo "端口18091未被占用"

# 检查应用健康状态
echo ""
echo "应用健康检查:"
curl -s http://localhost:18091/actuator/health 2>/dev/null && echo "应用运行正常" || echo "应用可能未启动或健康检查端点不可用"
